#{extends 'admintemplate.html'/}
#{set title:'Danh muc bai viet'/}
#{set main_title:'Quan ly danh muc'/}
#{set sub_title:'THem xoa sua bai viet'/}
#{set current_category:'active'/}
#{set 'moreScripts'}
        <script type="text/javascript">
			function deleteCategory(id){
				jQuery.ajax({
				  url: '/admin/categoryDelete/' + id,
				  success: function(rs) {
					  if(rs == "true"){
						  jQuery("#categoryId").val("");
						  window.location.reload();
					   }
				  }
				});
			}
			function loadContent(idString){
				jQuery.ajax({
				  url: '@{Admin.categoryFind}/' + idString,
				  success: function(rs) {
					  jQuery("#addCategoryForm input[name=name]").val(rs.name);
					  jQuery("#addCategoryForm textarea[name=description]").val(rs.description);
					  jQuery("#addCategoryForm input[name=categoryId]").val(rs.id);
					  jQuery("#addCategoryForm input[name=top]").val(rs.topAdv);
					  jQuery("#addCategoryForm input[name=bottom]").val(rs.bottomAdv);
					  jQuery("#addCategoryForm input[name=left]").val(rs.leftAdv);
					  jQuery("#addCategoryForm input[name=right]").val(rs.rightAdv);
					  jQuery("#addCategoryForm input[name=main]").val(rs.mainAdv);
				  }
				});
			}
		</script>
#{/set}
<div class="span12">
	#{if categories.size() !=0 }
	<div id="table-content">
		<table id="product-table">
		<tr>
			<th class="table-header-check"><a id="toggle-all" ></a> </th>
			<th class="table-header-repeat line-left minwidth-1"><a href="">Id</a>	</th>
			<th class="table-header-repeat line-left minwidth-1"><a href="">Name</a></th>
			<th class="table-header-repeat line-left minwidth-1"><a href="">Alias</a></th>
			<th class="table-header-options line-left"><a href="">Options</a></th>
		</tr>
		#{list items: categories, as:'category'}
			<tr>
				<td><input  type="checkbox"/></td>
				<td>${category?.id}</td>
				<td>${category?.name}</td>
				<td>${category?.alias}</td>
				<td class="options-width">
				<a href="#" onClick="loadContent(${category?.id})" title="Admin" class="">Edit</a>
				<a href="#" onClick="deleteCategory(${category?.id})" title="Delete" class="">Remove</a>
				</td>
			</tr>
		#{/list}
		#{pagination paginationInfo /}
		</table>
	</div>
	#{/if}
	<div class="well" style="padding: 16px 19px;">
		<form id="addCategoryForm" action="@{Admin.categoryCreate}" method="post" enctype="multipart/form-data" class="form">
			<fieldset>
				<div class="clearfix">
					<label for="name">Name</label>
					<div class="input">
						<input type="text" name="name">
					</div>
				</div>
				<div class="clearfix">
					<label for="data">File</label>
					<div class="input">
						<input type="file" name="data">
					</div>
				</div>
				<div class="clearfix">
					<label for="description">Description</label>
					<div class="input">
						<textarea rows="5" cols="200" name="description"></textarea>
					</div>
				</div>
				<div class="clearfix">
            		<label for="top">Top Banner</label>
            		<div class="input">
              			<textarea rows="3" name="top" id="ckeditor"></textarea>
           			 </div>
          		</div>
          		<div class="clearfix">
            		<label for="main">Main Banner</label>
            		<div class="input">
              			<textarea rows="3" name="main" id="ckeditor1"></textarea>
           			 </div>
          		</div>
          		<div class="clearfix">
            		<label for="left">Left Banner</label>
            		<div class="input">
              			<textarea rows="3" name="left" id="ckeditor2"></textarea>
           			 </div>
          		</div>
          		<div class="clearfix">
            		<label for="right">Right Banner</label>
            		<div class="input">
              			<textarea rows="3" name="right" id="ckeditor3"></textarea>
           			 </div>
          		</div>
          		<div class="clearfix">
            		<label for="bottom">Bottom Banner</label>
            		<div class="input">
              			<textarea rows="3" name="bottom" id="ckeditor4"></textarea>
           			 </div>
          		</div>
				<input type="hidden" name="categoryId" id="categoryId" />
				<div class="actions">
					<input type="submit" class="btn primary" value="Them/Cap nhat" />
				</div>
			</fieldset>
		</form>
	</div>
</div>
<!--  end content -->